﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GeneticAlgorithm.Demo.Common.Function.UnaryFunction
{
    [DisplayText(FunctionType.UnaryFunction4, "y=sin(πx)/πx")]
    internal class UnaryFunction4 : IUnaryFunction
    {
        public UnaryFunction4()
        {
            this.Range = (-10, 10);
            this.Solve = SolveType.Max;
            this.Accuracy = 3;
        }
        public (double lower, double upper) Range { get; set; }
        public byte Accuracy { get; set; }
        public SolveType Solve { get; set; }
        public int GeneMinLength => (int)Math.Ceiling(Math.Log2((Range.upper - Range.lower) * Math.Pow(10, Accuracy)));

        public double Func(double x)
        {
            return Math.Sin(Math.PI*x)/(Math.PI*x);
        }
    }
}
